/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entitesDB;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author CDI104
 */
@Entity
@Table(name = "PACKAGE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Package.findAll", query = "SELECT p FROM Package p"),
    @NamedQuery(name = "Package.findById", query = "SELECT p FROM Package p WHERE p.id = :id"),
    @NamedQuery(name = "Package.findByNompack", query = "SELECT p FROM Package p WHERE p.nompack = :nompack")})
public class Package implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private BigDecimal id;
    @Size(max = 255)
    @Column(name = "NOMPACK")
    private String nompack;
    @JoinTable(name = "PACKAGE_REVUE", joinColumns = {
        @JoinColumn(name = "packages_ID", referencedColumnName = "ID")}, inverseJoinColumns = {
        @JoinColumn(name = "listRevues_idRevue", referencedColumnName = "idRevue")})
    @ManyToMany
    private Collection<Revue> revueCollection;

    public Package() {
    }

    public Package(BigDecimal id) {
        this.id = id;
    }

    public BigDecimal getId() {
        return id;
    }

    public void setId(BigDecimal id) {
        this.id = id;
    }

    public String getNompack() {
        return nompack;
    }

    public void setNompack(String nompack) {
        this.nompack = nompack;
    }

    @XmlTransient
    public Collection<Revue> getRevueCollection() {
        return revueCollection;
    }

    public void setRevueCollection(Collection<Revue> revueCollection) {
        this.revueCollection = revueCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Package)) {
            return false;
        }
        Package other = (Package) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entitesDB.Package[ id=" + id + " ]";
    }
    
}
